<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" media="screen" type="text/css" href="__THEMES__/style/layout.css" />
		<script type="text/javascript" src="__JS__/jQuery/jquery.js"></script>
		<script type="text/javascript" src="__JS__/jQuery/plugin/troperate.js"></script>
		<script type="text/javascript" src="__JS__/jQuery/plugin/alertbox.js"></script>
		<include file="Public:js_artDialog" />
		<script type="text/javascript">
            $(function(){
            	$('#add_links').click(function(){
                    art.dialog.loadCall('{:U("add")}',{
						title : $(this).val(),
						lock : true
					}, false, function(){
						var ic = $('body',parent.document).find('#add_flink_submit');
						ic.submit(function(){
							if ( ic.find('#name').val() == '' ){
								setAlertBox('链接名称必须！', 2);
								ic.find('#name').addClass('errorInput').focus();
								return false;
							}
							$.post('__URL__/insert',ic.serialize(),function(c){
								setAlertBox(c.info, 2);
								if ( c.status === 0 ){
									return false;
								}else{
									window.location.href="{:U('index',array('tag'=>$_GET['tag']))}";
								}
							},'json');
							return false;
						});
					});
                });
            	
                $('#add_links_type').click(function(){
                    art.dialog.loadCall("{:U('addtype')}",{
						title : $(this).val(),
						lock : true
					}, false, function(){
						var ic = $('body',parent.document).find('#add_type_submit');
						ic.submit(function(){
							if ( ic.find('#type_name').val() == '' ){
								setAlertBox('链接分类名称必须！', 2);
								ic.find('#type_name').addClass('errorInput').focus();
								return false;
							}
							$.post("__URL__/insertlinktype",ic.serialize(),function(c){
								setAlertBox(c.info, 2);
								if ( c.status === 0 ){
									return false;
								}else{
									window.location.reload();
								}
							},'json');
							return false;
						});
					});
                });
                
                
                $('.edit_links_type').click(function(){
                    var url = $(this).attr('href');
                    art.dialog.loadCall(url,{
						title : '编辑链接分类',
						lock : true
					}, false, function(){
						var ic = $('body',parent.document).find('#edit_type_submit');
						ic.submit(function(){
							if ( ic.find('#type_name').val() == '' ){
								setAlertBox('链接分类名称必须！', 2);
								ic.find('#type_name').addClass('errorInput').focus();
								return false;
							}
							$.post("__URL__/updatelinktype",ic.serialize(),function(c){
								setAlertBox(c.info, 2);
								if ( c.status === 0 ){
									return false;
								}else{
									window.location.reload();
								}
							},'json');
							return false;
						});
					});
                    return false;
                });
                
            });
            
        </script>
	</head>
	<body>
		
		<include file="Public:position" />
		
		<div class="button">
            <input type="button" value="新增友情链接" class="submit" id="add_links"  /> &nbsp;&nbsp; 
            <input type="button" value="新增链接分类" class="submit" id="add_links_type"  /> &nbsp;&nbsp; 
            <input type="button" value="友情链接管理" class="submit" id="flink_type_list" onclick="window.location.href='{:U('index',array('tag'=>$_GET['tag']))}';"  />
        </div>
                              
        <div class="a_table">
            <table width="100%">
                <tr style="background: #f0f7ff; font-weight: bold;">
                    <td width="60" align="center" class="left_text">编号</td>
                    <td align="center" class="left_text">名称</td>
                    <td width="160" align="center" class="left_text">操作</td>
                </tr>
                <volist id="vo" name="list">
                <tr rel="{$vo['id']}" class="row_color"<?php if( ( $i % 2 ) == 0 ){ ?> bgcolor="#f9f9f9"<?php } ?>>
                    <td align="center">{$vo['id']}</td>
                    <td>{$vo.type_name}</td>
                    <td align="center">
                        <a href="{:U('edittype',array(
                        'id' => $vo['id'],
                        'typeid' => $vo['typeid'],
                        'tag' => $_GET['tag'],
                    ))}" class="edit_links_type">编辑</a><span class="action_line">|</span><a href="{:U('typedelete',array(
                        'id' => $vo['id'],
                    ))}" class="del_node" rel="{$vo.id}">删除</a>
                    </td>
                </tr>
                </volist>
            </table>
            
        </div>
		
	</body>
</html>